package com.wjh.anyview.websocket.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.websocket.Session;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author wjh
 * @date 2021/10/11 17:36
 * @Package com.wjh.anyview.websocket.util
 */
@Component
@SuppressWarnings("all")
public class SessionDataStore {
    @Autowired
    private  RedisTemplate redisTemplate;

    public boolean putSessionMap(String key, ConcurrentHashMap<String, Session> map) {
        redisTemplate.opsForHash().putAll(key, map);
        return true;
    }


    public ConcurrentHashMap<String, Session> getSessionMap(String key) {
        return (ConcurrentHashMap<String, Session>) redisTemplate.opsForHash().entries(key);
    }
}
